package com.service.product.controller;


import com.service.product.Product;
import com.service.product.service.ProductService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RequestMapping("/api/product")
@RestController
@RefreshScope//自动刷新配置中心的bean
public class ProductController {

    @Value("${expire.time-out}")
    private String expireTime;

    @Value("${auto-confirm}")
    private String autoConfirmTime;

    @Autowired
    private ProductService productService;

    @Operation(summary = "测试自动获取配置中心值的变更")
    @GetMapping("/getLatestModify")
    public void getLatestModify(){
        System.out.println("过期时间："+expireTime);
        System.out.println("确认时间："+autoConfirmTime);
    }

    @Operation(summary = "创建产品")
    @GetMapping("/createProduct")
    public Product createProduct(){
        log.info("产品服务被调用！！！");
        return productService.createProduct();
    }
}
